package cn.com.ethos.search.index;

import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;

public class Field {
	private String name;
	private Store store;
	private Index index;
	private long  boost;

	public Field(String name,String store,String index,long boost) 
				throws IllegalArgumentException {
		this.name  = name;
		this.boost = boost;
		
		if(store.equalsIgnoreCase(Store.COMPRESS.toString())) {
			this.store = Store.COMPRESS;
		} else if(store.equalsIgnoreCase(Store.YES.toString())) {
			this.store = Store.YES;
		} else if(store.equalsIgnoreCase(Store.NO.toString())) {
			this.store = Store.NO;
		} else {
			throw new IllegalArgumentException("Can't recgnize the store paramter");
		}
		if(index.equalsIgnoreCase(Index.NO.toString())) {
			this.index = Index.NO;
		} else if(index.equalsIgnoreCase(Index.NO_NORMS.toString())) {
			this.index = Index.NO_NORMS;
		} else if(index.equalsIgnoreCase(Index.TOKENIZED.toString())) {
			this.index = Index.TOKENIZED;
		} else if(index.equalsIgnoreCase(Index.UN_TOKENIZED.toString())) {
			this.index = Index.UN_TOKENIZED;
		} else {
			throw new IllegalArgumentException("Can't recgnize the index paramter");
		}
		
	}
	public Field(String name,String store,String index) throws IllegalArgumentException{
		this(name,store,index,1);
	}
	public long getBoost() {
		return this.boost;
	}
	public String getName() {
		return name;
	}
	public Store getStore() {
		return this.store;
	}
	public Index getIndex() {
		return index;
	}
}